#ifndef __G_TEST_APP_H__
#define __G_TEST_APP_H__


#include "GImage.h"
#include "GTask.h"
#include "GParallelForTask.h"
#include "GTaskResult.h"
#include "GModule.h"
#include "GMatrix4x4.h"
#include "GApplication.h"
#include "GRange.h"
#include "GModuleDescriptor.h"

#include "GInput.h"
#include "GInputComponent.h"

#define UPDATE_COUNT		8
#define UPDATE_GRANULARITY	64
#define UPDATE_MATRIX_COUNT	2048

class MultiplyTask : public GEngine::GParallelForTask
{
private:
	GMath::GMatrix4x4*		OutputArr;
	GMath::GMatrix4x4*		ViewProj;
	
public:
							MultiplyTask(GMath::GMatrix4x4* ViewProj, GMath::GMatrix4x4* OutputArr);
	virtual					~MultiplyTask();
	
	void					CreateRandom(INOUT GMath::GMatrix4x4* Matrix);
	
	virtual void			Execute(GSize Index, GSize WorkerId);
};

class RootTask : public GEngine::GTask
{
private:
	GMath::GMatrix4x4		ViewProj;
	GMath::GMatrix4x4		Outputs[UPDATE_MATRIX_COUNT];

public:
							RootTask(GEngine::GTaskResult* TaskResult, GEngine::GTaskPriority TaskPriority, bool TaskThreadSafe);
	virtual					~RootTask();

	virtual GUInt32			Execute(GSize WorkerId);
};

#define G_FRAME_COUNTS	100

class GTestApp : public GEngine::GApplication
{
G_MODULE(GTestApp);

protected:
	GUInt32				FrameId;
	double				RootTimes[G_FRAME_COUNTS];

	GEngine::GImage		Image;

						GTestApp();
	virtual				~GTestApp();

public:
	virtual bool		Update(float ElapsedTime);

	virtual bool		Initialize() OVERRIDE;
	virtual void		Uninitialize() OVERRIDE;
};

#endif